package com.jsbj.user.controller;


import com.jsbj.base.ResultBean;
import com.jsbj.framework.controller.BaseController;
import com.jsbj.user.entities.SysRolePermission;
import com.jsbj.user.service.ISysRolePermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 角色-菜单信息表 前端控制器
 * </p>
 *
 * @author jsbj
 * @since 2022-03-07
 */
@RestController
@RequestMapping("/sys-role-permission")
@ApiIgnore
@Api(value = "菜单权限配置", tags = "菜单权限配置")
public class SysRolePermissionController extends BaseController {

    @Autowired
    private ISysRolePermissionService sysRolePermissionService;

    @ApiOperation(value = "菜单配置")
    @PostMapping("/add")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "tenantCode", value = "租户id", required = true),
            @ApiImplicitParam(paramType = "header", dataType = "Integer", name = "userId", value = "用户登录id", required = true)}
    )
    public ResultBean<Integer> add(@RequestBody String inParam) {
        return new ResultBean<>(sysRolePermissionService.add(inParam));
    }

    @ApiOperation(value = "详情")
    @ResponseBody
    @PostMapping("/detail")
    @ApiImplicitParams({@ApiImplicitParam(paramType = "header", dataType = "String", name = "tenantCode", value = "租户id", required = true),
            @ApiImplicitParam(paramType = "header", dataType = "Integer", name = "userId", value = "用户登录id", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "id", value = "数据id", required = true)}
    )
    public ResultBean<List<SysRolePermission>> detail(@RequestParam String id) {
        return new ResultBean<>(sysRolePermissionService.detail(id));
    }
}

